import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTextArea;
import javax.swing.JTextField;


public class WelcomeMenu extends JPopupMenu{
	private static final long serialVersionUID = 1L;
	
	public WelcomeMenu(){
		//super("Welcome to Poker");
		
		setVisible(true);
		setPreferredSize(new Dimension(400,300));
		
		final SettingsMenu sMenu = new SettingsMenu();
		JPanel settingsPanel = new JPanel();
		settingsPanel.setLayout(null);
		
		JButton host = new JButton("Host Game");
		JButton join = new JButton("Join Game");
		final JTextField joinIP = new JTextField();
		JButton settings = new JButton("Settings");
		JTextArea disc = new JTextArea("                                           Welcome to Poker! \n" +
									   "                To begin a new game Please enter the IP address of\n" +
									   "                    a Hosting Player, or select 'Host Game' to begin\n" +
									   "                                    hosting a game of your own.");
		
		settingsPanel.add(host);
		settingsPanel.add(join);
		settingsPanel.add(joinIP);
		settingsPanel.add(settings);
		settingsPanel.add(disc);
		
		disc.setBounds(10,15,380,75);
		host.setBounds(290,100,100,25);
		joinIP.setBounds(30,100,150,25);
		join.setBounds(190,100,100,25);
		settings.setBounds(150,200,100,25);
				
		//Actions for the buttons
		host.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setVisible(false);
				Game.startServer();
			}
		});
				
		join.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setVisible(false);
				Game.startClient(joinIP.getText());
			}
		});
		
		settings.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				sMenu.setVisible(true);
			}
		});
		
		add(settingsPanel);
		pack();
		
	}

}